package com.example.demo.mapper;


import com.example.demo.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @author yanglup
 * @create 2020-11-19 19:24
 */
@Mapper
public interface GoodsMapper {
    /**添加图书*/
    //待--用户id这样的
    @Insert("insert into goodsaddtable(cat_id,goods_name,goods_price,goods_number,school,goods_oldnew,goods_described,goods_small_logo,goods_small_logo2,goods_small_logo3,cat_one_id,cat_two_id,goods_serial,openid,status) " +
            "values (#{cat_id},#{goods_name},#{goods_price},#{goods_number},#{school},#{goods_oldnew},#{goods_described},#{goods_small_logo},#{goods_small_logo2},#{goods_small_logo3},#{cat_one_id},#{cat_two_id},#{goods_serial},#{openid},#{status});")
    void Goodsaddmapperinsert(@Param("cat_id") Integer cat_id, @Param("goods_name") String goods_name,
                              @Param("goods_price") Integer goods_price, @Param("goods_number") Integer goods_number,
                              @Param("school") String school, @Param("goods_oldnew") String goods_oldnew,
                              @Param("goods_described") String goods_described, @Param("goods_small_logo") String goods_small_logo,
                              @Param("goods_small_logo2") String goods_small_logo2, @Param("goods_small_logo3") String goods_small_logo3,
                              @Param("cat_one_id") Integer cat_one_id, @Param("cat_two_id") Integer cat_two_id,
                              @Param("goods_serial") String goods_serial, @Param("openid") String openid, @Param("status") Integer status);




    /**查询第一个大的*/
    @Select("select * from goodsfenleitable1;")
    List<Goodsfenlei1> Goodsqueryselect1();
    /**查询第二个大的*/
    @Select("select * from goodsfenleitable2 limit #{number1},#{number2};")
    List<Goodsfenlei2> Goodsqueryselect2(Integer number1, Integer number2);





    /**商品列表--查询--分类里跳转1*/
    @Select("select goods_id,cat_id,goods_name,goods_price,school,goods_small_logo from goodsaddtable where cat_one_id=#{cat_one_id} and cat_two_id= #{cat_two_id} and status=0 limit #{pagenum},#{pagesize};")
      List<Goodlist> Goodsquerylist(Integer cat_one_id, Integer cat_two_id, Integer pagenum, Integer pagesize);
    /**商品列表查某分类里数量*/
    @Select("select count(*)  from goodsaddtable where cat_one_id=#{cat_one_id} and cat_two_id= #{cat_two_id} and status=0 ;")
    Integer Goodsquerylistcount(Integer cat_one_id, Integer cat_two_id);







    /**商品详情1*/
    @Select("select goods_id,cat_id,goods_name,goods_price,goods_number,goods_described,goods_oldnew,school,goods_small_logo,status from goodsaddtable where goods_id=#{goods_id};")
    Goodsdetail1 Goodsquerydetail1(Integer goods_id);
    /**插入图片3张*/
    @Insert("insert into goodsdetail2(goods_id,pics_mid) values(#{goods_id},(select goods_small_logo from goodsaddtable where goods_id=#{goods_id}));")
    void Goodsdetail2insert1(Integer goods_id);
    @Insert("insert into goodsdetail2(goods_id,pics_mid) values(#{goods_id},(select goods_small_logo2 from goodsaddtable where goods_id=#{goods_id}));")
    void Goodsdetail2insert2(Integer goods_id);
    @Insert("insert into goodsdetail2(goods_id,pics_mid) values(#{goods_id},(select goods_small_logo3 from goodsaddtable where goods_id=#{goods_id}));")
    void Goodsdetail2insert3(Integer goods_id);
    /**商品详情2*/
    @Select("select * from goodsdetail2 where goods_id=#{good_id};")
    List<Goodsdetail2> Goodsquerydetail2(Integer goods_id);






    /**搜索商品*/
    @Select("select goods_id,goods_name,goods_price,school from goodsaddtable where status=0 and goods_name like CONCAT('%',#{query},'%');")
    List<Goodsquerybookname> Goodsquerybookname(String query);




    /**反馈信息*/
    @Insert("insert into feedbacktable(minproblem,url,textVal) values (#{minproblem},#{url},#{textVal});")
    void Feedbackinsert(@Param("minproblem") String minproblem, @Param("url") String url, @Param("textVal") String textVal);



    /**删除商品*/
    @Delete("delete from goodsaddtable where openid=#{openid} and goods_id=#{goods_id}")
    void deletegoods(String openid, Integer goods_id);

}
